package org.starapp.rbac.rest;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;

public class RestDelete {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {

//			//1.参数放进一个list集合当中，每个参数是一个NameValuePair对象   
//		    List<NameValuePair> paramPair = new ArrayList<NameValuePair>();   
//		    if(params != null && !params.isEmpty()){  
//		        for(Map.Entry<String, String> entry : params.entrySet()){  
//		            paramPair.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));  
//		        }  
//		    }  
//		    //2.创建请求实体对象，参数集合作为构造参数   
//		    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramPair, "utf-8");  
//		    //3.创建post请求，并把实体对象放进去   
//		    HttpPost post = new HttpPost(path);  
//		    post.setEntity(entity);  
			
			
			
			// TODO Auto-generated method stub
			DefaultHttpClient httpclient = new DefaultHttpClient();
			// 代理的设置
			// 目标地址
			HttpGet httppost = new HttpGet(
					"http://localhost:8888/starapp-demo/api/v1/users/delete/admin");
//
//			StringEntity reqEntity = new StringEntity("?userId=admin"); 
//			HttpParams params =new BasicHttpParams();
//			params.setParameter("userId", "admin");
//			reqEntity.setContentType("application/x-www-form-urlencoded");
//			// 设置请求的数据
//			//httppost.setEntity(reqEntity);
//			
//			httppost.setParams(params);

			HttpResponse response = httpclient.execute(httppost);
			System.out.println("======="
					+ EntityUtils.toString(response.getEntity()));
			httpclient.getConnectionManager().shutdown();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
